package org.geometerplus.zlibrary.core.filetypes;

import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.util.MimeType;

import java.util.List;

class FileTypeCeb extends FileType {
	FileTypeCeb() {
		super("ceb");
	}

	@Override
	public boolean acceptsFile(ZLFile file) {
		final String extension = file.getExtension();
		return
			"ceb".equalsIgnoreCase(extension) ||
			"opf".equalsIgnoreCase(extension);
	}

	@Override
	public List<MimeType> mimeTypes() {
		return MimeType.TYPES_CEB;
	}

	@Override
	public MimeType mimeType(ZLFile file) {
		final String extension = file.getExtension();
		if ("ceb".equalsIgnoreCase(extension)) {
			return MimeType.APP_CEB;
		}
		// TODO: process other extensions (?)
		return MimeType.NULL;
	}

	@Override
	public MimeType rawMimeType(ZLFile file) {
		final String extension = file.getExtension();
		if ("ceb".equalsIgnoreCase(extension)) {
			return MimeType.APP_CEB;
		}
		// TODO: process other extensions (?)
		return MimeType.NULL;
	}

	@Override
	public String defaultExtension(MimeType mime) {
		return "ceb";
	}
}
